By: Kurt Stam (kurt.stam@jboss.com)
JBoss ESB JBoss Labs Home Page: http://labs.jboss.com/portal/jbossesb
JBoss ESB Developer Community Forums: http://www.jboss.com/index.html?module=bb&op=viewforum&f=220
########################################################################
# JBoss, Home of Professional Open Source
# Copyright 2006, JBoss Inc., and individual contributors as indicated
# by the @authors tag. See the copyright.txt in the distribution for a
# full listing of individual contributors.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this software; if not, write to the Free
# Software Foundation, Inc.,
# 02110-1301
########################################################################
1. Introduction
As part of the Loan Broker Demo, the broker goes out to a few banks to obtain loan quotes.
This folder contains two banks:
1. a Flat File Based Bank, and
2. a JMS Based bank.
To make the demo a little more interesting we have the banks use two different protocols (flat file and JMS), and two different message formats (csv, xml). You can customize some of the configuration in the bank.properties file. Not that the banks use to log4j.xml in the current directory.
The Flat File Based Bank uses the property 'file.monitored.directory' which by default is set to 'C:\Temp\BankInput'. You can start this bank by typing:
ant runFileBank
* Not of caution, there is
no filter set in the poller code, so it will pick up
and try to move any files it finds.
The FlatFilePollManager monitors a directory specified in the configuration. When a file arrives it tries to process the content assuming it contains one line with loan request information. So for example the content of the file could read something like
23456890,3,4,20000,5
The order of values needs to be SocialSecurityNumber, CreditScore, HistoryLength [month], LoanAmount [dollar], and finally the LoanTerm [month]. The request will be processed and a BankQouteReply is generated. The original file is moved to a 'processed' directory, and the BankQuoteReply is serialized to an 'outgoing' directory from the it can be picked up by the system that dropped the request.
You can test whether or not the bank is working by dropping a file in the monitored directory (C:\Temp\BankInput).Let's say we use a file with name 'request.txt'. The file should be ASCII and can contain the following line:
23456890,3,4,20000,5
The file should get moved to the C:\Temp\BankInput\processed directory, and in the C:\Temp\ BankInput\outgoing directory a reply file should appear with the name 'reply_to_request.txt'. It should contain the line:
8.29,FileBasedBank-1,0
which means the QuoteId=FileBasedBank-1, the interest=8.29 and the errorCode=0 (which means success). You can check the logging for additional details.
Before
starting the bank you need to bring up your JMS provider. For the example this
is the JBoss AS. We are using the default queues (C and D). The JMS bank uses the properties: jms.provider.url, jms.queue.in
and jms.queue.out. By default these are set to 'localhost',
'queue/C' and 'queue/D'. So, by default, it assumes
ant runJMSBank
The JMSManager listens to an incoming queue (by default queue/C on localhost). It consumes the message assuming it is a TextMessage, and that the text is an XML structure that can be marshaled into a BankQuoteRequest. The request will be processed and a BankQuote Reply will be serialized to XML and send to the outgoing queue (by default this is queue/D on localhost). If the processing results in an error a BankQuoteReply with ErrorCode other then 0 is send to the outgoing queue.
The unit test JMSProcessorTest drops a BankQuoteRequest Message on the queue/C of localhost. You can use
this test to check the health of the JMSBank. The tests can be executed by typing
ant test
You are now ready to run the larger Load Broker Demo itself.